<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        console.log('1');
        new Promise(resolve => {
            console.log('2');
            resolve()
        }).then(() => {
            console.log('3');
            Promise.resolve(1).then(() => {
                console.log('4');
                Promise.resolve(2).then(() => {
                    console.log('8');
                })
                setTimeout(() => {
                    console.log('7');
                })
            })
        })
        setTimeout(() => {
            console.log('5');
        })
        console.log('6');
        // 1 2 6 3 4 5 7
    </script>
</body>
</html>